﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;

namespace APH.Parl2.DataAccess.Repositiory
{
    interface IUnitOfWork
    {
        void Commit();
    }

    public class UnitOfWork : IUnitOfWork, IDisposable
    {
        private readonly IObjectContext _objectContext;
        public UnitOfWork(IObjectContext objectContext)
        {
            _objectContext = objectContext;
        }
        public void Dispose()
        {
            if (_objectContext != null)
            {
                _objectContext.Dispose();
            }
            GC.SuppressFinalize(this);
        }
        public void Commit()
        {
            _objectContext.SaveChanges();
        }
    }
}
